package com.bogewang.feignconsumer.web;

import com.bogewang.feignconsumer.HelloService;
import com.bogewang.feignconsumer.RefactorHelloService;
import com.bogewang.feignconsumer.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class FeignConsumerController {

    @Autowired
    HelloService helloService;

    @RequestMapping(value = "/feign-consumer", method = RequestMethod.GET)
    public String helloConsumer(){
        return helloService.hello();
    }

    @RequestMapping(value = "/feign-consumer2", method = RequestMethod.GET)
    public String helloConsumer2(){
        StringBuilder sb = new StringBuilder();
        sb.append(helloService.hello()).append("\n");
        sb.append(helloService.hello("bogewang")).append("\n");
        sb.append(helloService.hello("bogewang", 30)).append("\n");
        sb.append(helloService.hello(new User("bogewang", 30))).append("\n");
        return sb.toString();
    }

    @Autowired
    private RefactorHelloService refactorHelloService;

    @RequestMapping(value = "/feign-consumer3", method = RequestMethod.GET)
    public String helloConsumer3(){
        StringBuilder sb = new StringBuilder();
        sb.append(refactorHelloService.hello("MIMI")).append("\n");
        sb.append(refactorHelloService.hello("bogewang", 30)).append("\n");
        sb.append(refactorHelloService.hello(new com.bogewang
                .helloserviceapi.dto.User("bogewang", 30))).append("\n");
        return sb.toString();
    }

}
